#pragma once

#include <QVariant>
#include <QMetaType>
#include <vector>
#include<iostream>
#include <QObject>
#include <QThread>
#include<QString>
#include "list_message.h"
#include "QDateTime"
#include <opencv2/opencv.hpp>
using namespace cv;

using namespace std;

#include <atomic>

#include "spdlog/spdlog.h"
#include "spdlog/sinks/daily_file_sink.h"
#include "spdlog/fmt/ostr.h"
extern std::shared_ptr<spdlog::logger> logger ;

#include "save_image.h"



#include <QTimer>

#include "function.h"


class VectorOutputResult
{
public:
    cv::Mat m_image;
    cv::Mat m_image_draw;
    int m_camera_index;
    int m_detection_index;
    bool m_detectin_result;
    QString m_camera_name;
    QString m_messgae;
    double m_time_use ;
	int m_detection_times = 0;
	int m_save_right = 0;
	int m_save_wrong = 0;
	int m_save_right_label = 0;
	int m_save_wrong_label = 0;

};//<描述一个相机单次检测完后的需要输出到主界面的统计显示信息

class QtThreadProcess : public QObject
{
    Q_OBJECT
public:
    explicit QtThreadProcess(QObject* parent = nullptr);
   

public:





    Function* m_function;


    int m_io_camera=0;

    int m_io_result=0;
    int m_io_finish=0;

	
    

    QString m_camera_name;
    int m_station ;
    QStringList m_detection_types_name;

    vector<int> m_plc_write ;

    vector<cv::Rect> m_vector_roi;


    QString m_image_dir = "";
    vector<QString> m_images_path;

	

    bool  m_proess_state = false ;

    bool m_only_show_state = false  ;

    int  m_plc_read;

    uint m_detection_number =1;

    

   

    uint64_t  m_camera_index = 0;//相机的序号


    double m_time_use =0;


   uint64_t m_image_index ;//相机采图图像序号

    uint64_t  m_detection_index = 0;//检测序号

	int m_detection_times = 0;

   //检测线程中ng和ok的个数
    uint64_t  m_ng_count=0;

    uint64_t  m_ok_count=0;

    uint64_t  m_ng_segmentation_count=0;

    uint64_t m_defect_unknow_count=0;

    ListMessgae<cv::Mat>	m_qDisplayFrameQueue;		///< 待处理显示原始图像队列（输入图像缓冲）

signals:
   void sendDetectionResult(VectorOutputResult result);///<相机对象处理完图像后要发射的信号
   void sendComResult(short data1, short value, short data3);///
   void sendCameraFinish(short data);///
   void sendShowImage(Mat image,int camera_index,int index);///<相机对象处理完图像后要发射的信号
public slots:
//	virtual void run();

};


extern void callback(Mat image,void* p);



